<?php defined('SYSPATH') or die('No direct script access.');

class Controller_Book_Category extends Controller{

public function action_index()
{
}

public function action_list()
{
	$query_result = ORM::factory('category')->order_by('order')->find_all();
	$result = $this->create_category_list($query_result->as_array());
	echo json_encode($result);
}

protected function create_category_list($array)
{
	$object = array();
	foreach ( $array as $category)
	{
		array_push($object,
			array(
				'id'	=> $category->id,
				'name'  => $category->name,
			));
	}
	return array(
		'count' => count($object),
		'data'  => $object
	);
}

}


